{% extends "projects/base.html" %}

{% load i18n %}
{% load project_tags %}
{% load comments_tag %}

{% block head_title %}{{ task.summary }}{% endblock %}

{% block body %}
    <p><a href="{% url project_tasks task.project.slug %}">&larr; {% trans "Back to Task List for Project " %} {{ task.project }}</a></p>
    
    {% show_task task %}
    
    {% ifequal request.user task.assignee %}
    <form action="" method="POST">
        <table>
            {{ status_form }}
            <tr><td></td><td><input type="submit" value="{% trans "Update Status" %}" /></td></tr>
        </table>
        <input type="hidden" name="action" value="update_status" />
    </form>
    {% else %}
        <div><b>Status</b>: {{ task.status }}</div>
    {% endifequal %}
    
    {% if is_member %}
        <form action="" method="POST">
            <table>
                {{ assign_form }}
                {% if task.assignee %}
                    <tr><td></td><td><input type="submit" value="{% trans 'Reassign' %}" /></td></tr>
                {% else %}
                    <tr><td></td><td><input type="submit" value="{% trans 'Assign' %}" /></td></tr>
                {% endif %}
            </table>
            <input type="hidden" name="action" value="assign" />
        </form>
    {% endif %}
    
    {% ifequal task.get_state_display 'open' %}
        {% ifequal request.user task.assignee %}
            <form action="" method="POST">
                <input type="hidden" name="action" value="mark_resolved" />
                <input type="submit" value="{% trans 'Mark Resolved' %}" />
            </form>
        {% endifequal %}
    {% else %}
        {% ifequal task.get_state_display 'resolved' %}
            {% ifequal request.user task.creator %}
                <form action="" method="POST">
                    <input type="hidden" name="action" value="mark_closed" />
                    <input type="submit" value="{% trans 'Mark Closed' %}" />
                </form>
            {% endifequal %}
            {% if is_member %}
                <form action="" method="POST">
                    <input type="hidden" name="action" value="reopen" />
                    <input type="submit" value="{% trans 'Reopen' %}" />
                </form>
            {% endif %}
        {% else %}
            {% if is_member %}
                <form action="" method="POST">
                    <input type="hidden" name="action" value="reopen" />
                    <input type="submit" value="{% trans 'Reopen' %}" />
                </form>
            {% endif %}
        {% endifequal %}
    {% endifequal %}
    
    <h2>Discussion</h2>
    {% comments task %}
{% endblock %}